package org.theSeed.contract.impl;

import org.springframework.stereotype.Component;
import org.theSeed.contract.ThreadCache;
import org.theSeed.pojo.dto.UserInfoUserDetails;
import org.theSeed.rbacBaseCommon.pojo.constant.RbacConstant;

/**
 * token线程缓存
 */
@Component
public class UserInfoThreadCacheImpl implements ThreadCache<UserInfoUserDetails> {
    private InheritableThreadLocal<UserInfoUserDetails> threadLocal = new InheritableThreadLocal<>();

    @Override
    public UserInfoUserDetails getData() {
        return threadLocal.get();
    }

    @Override
    public void setData(UserInfoUserDetails data) {
        threadLocal.set(data);
    }

    @Override
    public void clear() {
        threadLocal.remove();
    }

    @Override
    public String handlerType() {
        return RbacConstant.LOGIN_THREAD_CACHE;
    }
}
